﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using blackhouse.BlackApart.Business.Reservations;
using blackhouse.Aparts.Web.DataSources;
using mojoPortal.Business.WebHelpers;
using blackhouse.JavaScript.JQuery;

namespace blackhouse.Aparts.Web.Modules {
    public partial class Interviewer : UserControl {

        #region Properties

        public int ReservationId { get; set; }

        #endregion

        #region Event Handlers

        protected override void OnInit(EventArgs e) {
            base.OnInit(e);

            this.Visible = Request.IsAuthenticated && WebUser.IsInRole("Interviewer");
        }

        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);

            if (this.Visible) {
                this.SetScenario();
                this.PopulateView();
            }
        }

        #endregion

        #region Methods

        private void SetScenario() {
        }

        private void PopulateView() {
            string lnk = "/Pages/InterviewerContent.aspx";
            if (ReservationId > 0) 
                lnk = lnk + "?reservation=" + this.ReservationId;
            this.iframe.Attributes.Add("src", lnk);

            JQueryLibraries jql = new JQueryLibraries();
            jql.IncludeFileBasedOnJQuery("blackhouse.Aparts.Web.Scripts.interviewer.js,blackhouse.Aparts.Web");
        }

        #endregion

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
            if (e.Row.RowType == DataControlRowType.DataRow) {
                HyperLink ctrl = e.Row.Cells[1].Controls[0] as HyperLink;
                ctrl.Text = (e.Row.DataItem as IWebReservation).GetGroupShortName();
            }
        }

    }
}